//首页
const express = require('express')
//引入连接池
const pool = require('../pool')
const Response = require("../utils/Response.js");
const router = express.Router()
router.post('/user/login', (req, res, next) => {
    let { username, password } = req.body
    let sql = "select * from admin where username=? and password=?"
    pool.query(sql, [username, password], (error, result) => {
        if (error) {
            res.send(Response.error(500, error));
            throw error;
        }
        if (result.length == 0) {
            res.send(Response.error(1001, '账号密码输入错误'));
        } else {
            res.send({ code: 200, msg: '登录', data: result })

        }
    })
})






module.exports = router